#ifndef REMOVEFILESTHREAD_H
#define REMOVEFILESTHREAD_H
#include <QFile>
#include <QThread>

class RemoveFilesThread : public QThread
{
    Q_OBJECT

public:
    explicit RemoveFilesThread(const QList<QString>& files, QObject* parent = nullptr)
        : QThread(parent), quit_requested_(false), files_(files)
    {
    }

    void setQuitRequested(bool requested) { quit_requested_ = requested; }

Q_SIGNALS:
    void removeFinished();

protected:
    void run() override
    {
        for (const QString& s : files_) {
            QFile::remove(s);
            if (quit_requested_) {
                break;
            }
        }
        if (!quit_requested_) {
            Q_EMIT removeFinished();
        }
    }

private:
    bool quit_requested_;
    QList<QString> files_;
};

#endif // REMOVEFILESTHREAD_H
